package com.example.service;

import com.example.entity.Model;
import com.example.entity.Notes;
import com.example.mapper.NotesMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
笔记业务处理
 */
@Service
public class NotesService {

    @Resource
    private NotesMapper notesMapper;

    public void add(Notes notes) {
        notesMapper.insert(notes);
    }

    public void deleteById(Integer id) {
        notesMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Notes notes) {
        notesMapper.updateById(notes);
    }

    public Notes selectById(Integer id) {
        return notesMapper.selectById(id);
    }

    public List<Notes> selectAll(Notes notes) {
        return notesMapper.selectAll(notes);
    }

    public PageInfo<Notes> selectPage(Notes notes, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Notes> notesList = notesMapper.selectAll(notes);
        return PageInfo.of(notesList);
    }
}
